
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.PigType;
import cn.edu.scau.cmi.hombio.domain.SaleTaskQuality;
import cn.edu.scau.cmi.hombio.domain.Task;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class SaleTaskQualityServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected SaleTaskQualityService service;

	/**
	 * Instantiates a new SaleTaskQualityServiceTest.
	 *
	 */
	public SaleTaskQualityServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing PigType entity
	* 
	 */
	@Test
	public void deleteSaleTaskQualityPigType() {
		// TODO: JUnit - Populate test inputs for operation: deleteSaleTaskQualityPigType 
		Integer saletaskquality_id = 0;
		Integer related_pigtype_id = 0;
		SaleTaskQuality response = null;
		response = service.deleteSaleTaskQualityPigType(saletaskquality_id, related_pigtype_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteSaleTaskQualityPigType
	}

	/**
	 * Operation Unit Test
	* Return all SaleTaskQuality entity
	* 
	 */
	@Test
	public void findAllSaleTaskQualitys() {
		// TODO: JUnit - Populate test inputs for operation: findAllSaleTaskQualitys 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<SaleTaskQuality> response = null;
		response = service.findAllSaleTaskQualitys(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllSaleTaskQualitys
	}

	/**
	 * Operation Unit Test
	* Save an existing PigType entity
	* 
	 */
	@Test
	public void saveSaleTaskQualityPigType() {
		// TODO: JUnit - Populate test inputs for operation: saveSaleTaskQualityPigType 
		Integer id = 0;
		PigType related_pigtype = new cn.edu.scau.cmi.hombio.domain.PigType();
		SaleTaskQuality response = null;
		response = service.saveSaleTaskQualityPigType(id, related_pigtype);
		// TODO: JUnit - Add assertions to test outputs of operation: saveSaleTaskQualityPigType
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findSaleTaskQualityByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findSaleTaskQualityByPrimaryKey 
		Integer id_1 = 0;
		SaleTaskQuality response = null;
		response = service.findSaleTaskQualityByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findSaleTaskQualityByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Load an existing SaleTaskQuality entity
	* 
	 */
	@Test
	public void loadSaleTaskQualitys() {
		Set<SaleTaskQuality> response = null;
		response = service.loadSaleTaskQualitys();
		// TODO: JUnit - Add assertions to test outputs of operation: loadSaleTaskQualitys
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteSaleTaskQualityTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteSaleTaskQualityTask 
		Integer saletaskquality_id_1 = 0;
		Integer related_task_id = 0;
		SaleTaskQuality response = null;
		response = service.deleteSaleTaskQualityTask(saletaskquality_id_1, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteSaleTaskQualityTask
	}

	/**
	 * Operation Unit Test
	* Delete an existing SaleTaskQuality entity
	* 
	 */
	@Test
	public void deleteSaleTaskQuality() {
		// TODO: JUnit - Populate test inputs for operation: deleteSaleTaskQuality 
		SaleTaskQuality saletaskquality = new cn.edu.scau.cmi.hombio.domain.SaleTaskQuality();
		service.deleteSaleTaskQuality(saletaskquality);
	}

	/**
	 * Operation Unit Test
	* Save an existing SaleTaskQuality entity
	* 
	 */
	@Test
	public void saveSaleTaskQuality() {
		// TODO: JUnit - Populate test inputs for operation: saveSaleTaskQuality 
		SaleTaskQuality saletaskquality_1 = new cn.edu.scau.cmi.hombio.domain.SaleTaskQuality();
		service.saveSaleTaskQuality(saletaskquality_1);
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveSaleTaskQualityTask() {
		// TODO: JUnit - Populate test inputs for operation: saveSaleTaskQualityTask 
		Integer id_2 = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		SaleTaskQuality response = null;
		response = service.saveSaleTaskQualityTask(id_2, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveSaleTaskQualityTask
	}

	/**
	 * Operation Unit Test
	* Return a count of all SaleTaskQuality entity
	* 
	 */
	@Test
	public void countSaleTaskQualitys() {
		Integer response = null;
		response = service.countSaleTaskQualitys();
		// TODO: JUnit - Add assertions to test outputs of operation: countSaleTaskQualitys
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
